<?php

/**
 * @category   Oos
 * @package    Oos_Site_Extension
 * @license    New BSD License
 */

require_once 'Zend/Gdata/Extension.php';
require_once 'Oos/Site/Extension/Point.php';

class Oos_Site_Extension_GeoRSS extends Zend_Gdata_Extension
{
	protected $_rootNamespace = 'georss';
    protected $_rootElement = 'where';
	protected $_point = null;
	
    public function __construct($point = null)
    {
    	foreach (Oos_Site::$namespaces as $nsPrefix => $nsUri) {
            $this->registerNamespace($nsPrefix, $nsUri);
        }
        parent::__construct();
        $this->_point = $point;
    }
    
    public function getDOM($doc = null)
    {	
        $element = parent::getDOM($doc);
        if ($this->_point != null) {
        	$x = $this->_point->getDOM($element->ownerDocument);
            $element->appendChild($x);
        }
        return $element;
    }
    
    protected function takeChildFromDOM($child)
    {
        $absoluteNodeName = $child->namespaceURI . ':' . $child->localName;
        switch ($absoluteNodeName) {
        case $this->lookupNamespace('gml') . ':' . 'Point':
            $point = new Oos_Site_Extension_Point();
            $point->transferFromDOM($child);
            $this->_point = $point;
            break;
        default:
            parent::takeChildFromDOM($child);
            break;
        }
    }

}

?>